﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gma.UserActivityMonitor;
using WindowsInput;
using System.IO;

namespace KeyRemapperTest
{
    public partial class Form1 : Form
    {

        private Dictionary<string, string> _remap = null;

        public Form1()
        {
            InitializeComponent();

            //Array keyStrings = Enum.GetNames(typeof(Keys));
            //Array virtualKeyStrings = Enum.GetNames(typeof(VirtualKeyCode));


            //string file1 =  String.Join(Environment.NewLine, (string[])keyStrings);
            //string file2 = String.Join(Environment.NewLine, (string[])virtualKeyStrings);

            //File.WriteAllText(@"c:\file1.txt", file1);
            //File.WriteAllText(@"c:\file2.txt", file2);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            _remap = new Dictionary<string, string>();
            _remap.Add("X", "Y");

            HookManager.KeyDown += new KeyEventHandler(HookManager_KeyDown);
        }

        void HookManager_KeyDown(object sender, KeyEventArgs e)
        {
            string code = e.KeyCode.ToString();
            
            lblKeyCode.Text = code;
            e.SuppressKeyPress = true;
            // if key is to be remapped
            //if (_remap.ContainsKey(e.KeyCode.ToString()))
            //{
            //    e.SuppressKeyPress = true;

            //    InputSimulator.SimulateKeyPress((VirtualKeyCode) Enum.Parse(typeof(VirtualKeyCode),"VK_Y"));
                
            //} // else ignore
            
        }

        private void tnEnd_Click(object sender, EventArgs e)
        {
            HookManager.KeyDown -= new KeyEventHandler(HookManager_KeyDown);
        }
    }
}
